package com.example.pingze.service;

import com.example.pingze.entity.Compete;
import com.example.pingze.repository.CompeteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompeteService {
    @Autowired
    private CompeteRepository repository;

    public Compete findCompeteByKeyWordAndContent(String keyWord, String content) {
        return repository.findCompeteByKeyWordAndContent(keyWord, content);
    }

    public Compete addCompete(Compete compete) {
        return repository.save(compete);
    }

    public List<Compete> findCompetesByKeyWord(String keyWord) {
        return repository.findCompeteByKeyWord(keyWord);
    }

    public Compete findCompeteByIdAndAccount(String id, String account) {
        return repository.findCompeteByIdAndAccount(id, account);
    }

//    public List<Compete> findCompetesByAccountAndKeyword(String account, String keyword) {
//        return repository.findCompetesByAccountAndKeyWord(account, keyword);
//    }

    public void deleteCompete(Compete compete) {
        repository.delete(compete);
    }
}
